package com.insurance.modules.claim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.insurance.common.utils.PageUtils;
import com.insurance.common.utils.Query;

import com.insurance.modules.claim.dao.ClaimSettlementDao;
import com.insurance.modules.claim.entity.ClaimSettlementEntity;
import com.insurance.modules.claim.service.ClaimSettlementService;


@Service("claimSettlementService")
public class ClaimSettlementServiceImpl extends ServiceImpl<ClaimSettlementDao, ClaimSettlementEntity> implements ClaimSettlementService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ClaimSettlementEntity> page = this.page(
                new Query<ClaimSettlementEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<ClaimSettlementEntity> list4case(String caseId, Integer settlementOrder) {
        LambdaQueryWrapper<ClaimSettlementEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ClaimSettlementEntity::getCaseId, caseId);
        if(null != settlementOrder){
            wrapper.eq(ClaimSettlementEntity::getSettlementOrder, settlementOrder);
        }
        wrapper.orderByAsc(ClaimSettlementEntity::getSettlementOrder);
        return getBaseMapper().selectList(wrapper);
    }

}